#include "windowcontroller.h"

WindowController::WindowController(LPCTSTR appClassName, LPCTSTR wndCaption)
	:Window(appClassName, wndCaption)
{
	//ctor
}

WindowController::~WindowController()
{
	//dtor
}

LRESULT CALLBACK WindowController::WindowProcedure
	(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	static int x=16;
	static int y=16;
	static bool s=false;

    switch(message) {
	case WM_KEYDOWN:

		switch(wParam) {
		case VK_LEFT:
			x-=16;
			break;
		case VK_RIGHT:
			x+=16;
			break;
		case VK_UP:
			y-=16;
			break;
		case VK_DOWN:
			y+=16;
			break;
		}
		InvalidateRect(hWnd,NULL,FALSE);//TRUE 하면 지우고 다시그리고... FALSE 는 지우지않고 그린다
		return 0;
	case WM_CHAR:
		_wModel->Fetch(message, wParam);
		switch(wParam) {
			case 'C':
				s=s^1;
				break;
			case 'V':
				//old = (WNDPROC)SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)WindowMessageHandler::gg);
				break;
		}
		break;
	case WM_PAINT:

		_wView->Draw(x ,y);


		return 0;
	case WM_DESTROY:
		//SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)old);
		PostQuitMessage(0);
		return 0;
	}
	return(DefWindowProc(hWnd,message,wParam,lParam));
}
